package ikelib;

public class winfilename {
	winfilename(){
		year=2010;
		month = day = 1;
		hour = min=0;
		name = new String("10010100.00");
		dir = new String("");
	}
	winfilename(int y,int m,int d,int h,int mi){
		makeName(y,m,d,h,mi);
	}
	winfilename(winfilename w){
		makeName(w.year,w.hour,w.day,w.hour,w.min);
	}
	public winfilename(String n){
		if(n.length() >= 11){
			dir = new String(n.substring(0,n.length()-11));
			String n1 = new String(n.substring(n.length()-11,n.length()));
			String y = new String(n1.substring(0,2));
			String m = new String(n1.substring(2,4));
			String d = new String(n1.substring(4,6));
			String h = new String(n1.substring(6,8));
			//String dot =  n.substring(8,9);
			String mi = new String(n1.substring(9,11));
			year = 2000+Integer.parseInt(y);
			month = Integer.parseInt(m);
			day = Integer.parseInt(d);
			hour = Integer.parseInt(h);
			min = Integer.parseInt(mi);
			makeName(year,month,day,hour,min);	
		}
	}
	private void makeName(int y,int m,int d,int h,int mi){
		name = new String();
		year = y;
		month = m;
		day = d;
		hour = h;
		min = mi;
		name = String.format("%02d%02d%02d%02d.%02d",year-2000,month,day,hour,min);
	}
	public String name(){
		return dir +  name;
	}
	public String nameInc(){
		wintime t = new wintime(year,month,day,hour,min,0);
		t.inc_min();
		makeName(t.year(),t.month(),t.day(),t.hour(),t.min());
		return name();
	}
	// 10071611.25 -> 2010/07/16 11:25
	private String dir;
	private String name;
	private int year;
	private int month;
	private int day;
	private int hour;
	private int min;
}
